package com.xyy.saas.payment.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author wangzeqi
 */
@Configuration
public class ThreadPoolConfig {

    @Bean("reconcileThreadPool")
    public ThreadPoolExecutor reconcileThreadPool() {
        return new ThreadPoolExecutor(4, 8, 10, TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(50),
                new CustomNameThreadFactory("reconcile"),
                new ThreadPoolExecutor.CallerRunsPolicy());
    }

    /*@Bean("reconcileStrategyThreadPool")
    public ThreadPoolExecutor reconcileStrategyThreadPool() {
        return new ThreadPoolExecutor(10, 20, 10, TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(100),
                new CustomNameThreadFactory("reconcileStrategy"),
                new ThreadPoolExecutor.CallerRunsPolicy());
    }*/

}
